<template>
  <div class="app-container">
    <!-- 输入表单 -->
    <el-form label-width="120px" >
      <el-form-item label="车主id">
        <el-input  v-model="car.customerId" style="width:400px" />
      </el-form-item>
      <el-form-item label="车辆头像">
        <el-input v-model="car.carImg" style="width:400px"/>
      </el-form-item>
       <el-form-item label="VIN号码">
        <el-input v-model="car.carNum" style="width:400px" />
      </el-form-item>
       <el-form-item label="车型">
        <el-input v-model="car.carModel" style="width:400px" />
      </el-form-item>
      <el-form-item label="里程数">
        <el-input v-model="car.carMileage" style="width:400px" />
      </el-form-item>
      <el-form-item label="保险公司">
        <el-input v-model="car.carInsuranceCompany" style="width:400px" />
      </el-form-item>
      <el-form-item label="保险到期时间">
        <el-input v-model="car.carInsuranceExpires" style="width:400px" />
      </el-form-item>
      <el-form-item label="备注">
        <el-input v-model="car.carRemarks" style="width:400px" />
      </el-form-item>
      <el-form-item>
        <el-button
          :disabled="saveBtnDisabled"
          type="primary"
          @click="save(car)"
        >
          保存
        </el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import carApi from '@/api/core/car'
export default {
  data() {
    return {
      car: {}, // 初始化数据
      saveBtnDisabled: false // 保存按钮是否禁用，防止表单重复提交
    }
  },
  methods: {
    saveOrUpdate() {
      // 禁用保存按钮
      this.saveBtnDisabled = true
      this.saveData()
    },
    // 新增数据
    saveData() {
      // debugger
      carApi.save(this.car).then(response => {
        this.$message({
          type: 'success',
          message: response.message
        })
        this.$router.push('/car/index')
      })
    }
}
}
</script>